package com.ruoyi.imports.domain;

import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.ruoyi.imports.anno.ExcelColumn;
import com.ruoyi.imports.anno.ExcelSheet;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
@ExcelSheet("生产数据")
public class ProductionExcelData implements Serializable {

    private static final long serialVersionUID = 1L;

    // 基础信息（0-9）
    @ExcelColumn(header = {"日期"}, order = 0, required = true)
    @DateTimeFormat("yyyy年MM月dd日")
    @ColumnWidth(15)
    private String date;

    @ExcelColumn(header = {"处理水量"}, order = 1)
    @ColumnWidth(12)
    private BigDecimal chuLiFeiShui;

    @ExcelColumn(header = {"人工费用"}, order = 2)
    @ColumnWidth(12)
    private BigDecimal renGongFeiYong;

    @ExcelColumn(header = {"维修费用"}, order = 3)
    @ColumnWidth(12)
    private BigDecimal weiXiuFeiYong;

    @ExcelColumn(header = {"其他费用"}, order = 4)
    @ColumnWidth(12)
    private BigDecimal qiTaFeiYong;

    @ExcelColumn(header = {"药剂费用"}, order = 5)
    @ColumnWidth(12)
    private BigDecimal yaoJiFeiYong;

    @ExcelColumn(header = {"日利润"}, order = 6)
    @ColumnWidth(12)
    private BigDecimal riLiRun;

    @ExcelColumn(header = {"大额费用支出说明（1000元以上）"}, order = 7)
    @ColumnWidth(12)
    private String daEFeiYong;

    @ExcelColumn(header = {"生产异常状况（安全事故、系统波动、成本持续上升、在线超标、重点设备故障等）"}, order = 8)
    @ColumnWidth(12)
    private String shengChanYiChang;

    @ExcelColumn(header = {"重点工作汇报"}, order = 9)
    @ColumnWidth(12)
    private String zhongDianGongZuo;


    // 生化药剂（10-19）
    @ExcelColumn(header = {"生化药剂", "磷酸二氢钠"}, order = 10)
    @ColumnWidth(12)
    private BigDecimal sodiumDihydrogenPhosphate;

    @ExcelColumn(header = {"生化药剂", "葡萄糖"}, order = 11)
    @ColumnWidth(12)
    private BigDecimal glucose;

    @ExcelColumn(header = {"生化药剂", "生物活性磷"}, order = 12)
    @ColumnWidth(12)
    private BigDecimal bioActivePhosphorus;

    @ExcelColumn(header = {"生化药剂", "消泡剂"}, order = 13)
    @ColumnWidth(12)
    private BigDecimal defoamer;

    @ExcelColumn(header = {"生化药剂", "液体乙酸钠"}, order = 14)
    @ColumnWidth(12)
    private BigDecimal liquidSodiumAcetate;

    @ExcelColumn(header = {"生化药剂", "复合碳源"}, order = 15)
    @ColumnWidth(12)
    private BigDecimal compositeCarbonSource;

    @ExcelColumn(header = {"生化药剂", "复合碱"}, order = 16)
    @ColumnWidth(12)
    private BigDecimal compositeAlkali;

    @ExcelColumn(header = {"生化药剂", "硫酸亚铁"}, order = 17)
    @ColumnWidth(12)
    private BigDecimal ferrousSulfate;

    @ExcelColumn(header = {"生化药剂", "液碱"}, order = 18)
    @ColumnWidth(12)
    private BigDecimal liquidAlkali;

    @ExcelColumn(header = {"生化药剂", "纯碱"}, order = 19)
    @ColumnWidth(12)
    private BigDecimal sodaAsh;


    // 后混凝深度处理药剂（20-32）
    @ExcelColumn(header = {"后混凝深度处理药剂", "DS-821"}, order = 20)
    @ColumnWidth(12)
    private BigDecimal ds821;

    @ExcelColumn(header = {"后混凝深度处理药剂", "DS-882"}, order = 21)
    @ColumnWidth(12)
    private BigDecimal ds882;

    @ExcelColumn(header = {"后混凝深度处理药剂", "次氯酸钠"}, order = 22)
    @ColumnWidth(12)
    private BigDecimal sodiumHypochlorite;

    @ExcelColumn(header = {"后混凝深度处理药剂", "DS-6031(液体)"}, order = 23)
    @ColumnWidth(12)
    private BigDecimal ds6031Liquid;

    @ExcelColumn(header = {"后混凝深度处理药剂", "DS-6031(固体)"}, order = 24)
    @ColumnWidth(12)
    private BigDecimal ds6031Solid;

    @ExcelColumn(header = {"后混凝深度处理药剂", "DS-832"}, order = 25)
    @ColumnWidth(12)
    private BigDecimal ds832;

    @ExcelColumn(header = {"后混凝深度处理药剂", "DS-7021"}, order = 26)
    @ColumnWidth(12)
    private BigDecimal ds7021;

    @ExcelColumn(header = {"后混凝深度处理药剂", "DS-8031"}, order = 27)
    @ColumnWidth(12)
    private BigDecimal ds8031;

    @ExcelColumn(header = {"后混凝深度处理药剂", "硫酸"}, order = 28)
    @ColumnWidth(12)
    private BigDecimal sulfuricAcid;

    @ExcelColumn(header = {"后混凝深度处理药剂", "DS-722"}, order = 29)
    @ColumnWidth(12)
    private BigDecimal ds722;

    @ExcelColumn(header = {"后混凝深度处理药剂", "液碱（32%）"}, order = 30)
    @ColumnWidth(12)
    private BigDecimal liquidAlkali32pct;

    @ExcelColumn(header = {"后混凝深度处理药剂", "液碱（10%）"}, order = 31)
    @ColumnWidth(12)
    private BigDecimal liquidAlkali10pct;

    @ExcelColumn(header = {"后混凝深度处理药剂", "片碱"}, order = 32)
    @ColumnWidth(12)
    private BigDecimal flakeAlkali;


    // 中水药剂（33-41）
    @ExcelColumn(header = {"中水药剂", "低磷阻垢缓蚀剂"}, order = 33)
    @ColumnWidth(12)
    private BigDecimal lowPhosphorusScaleInhibitor;

    @ExcelColumn(header = {"中水药剂", "柠檬酸"}, order = 34)
    @ColumnWidth(12)
    private BigDecimal citricAcid;

    @ExcelColumn(header = {"中水药剂", "熟石灰"}, order = 35)
    @ColumnWidth(12)
    private BigDecimal hydratedLime;

    @ExcelColumn(header = {"中水药剂", "生石灰"}, order = 36)
    @ColumnWidth(12)
    private BigDecimal quicklime;

    @ExcelColumn(header = {"中水药剂", "次粉"}, order = 37)
    @ColumnWidth(12)
    private BigDecimal wheatBran;

    @ExcelColumn(header = {"中水药剂", "非氧化杀菌剂"}, order = 38)
    @ColumnWidth(12)
    private BigDecimal nonOxidizingBiocide;

    @ExcelColumn(header = {"中水药剂", "还原剂"}, order = 39)
    @ColumnWidth(12)
    private BigDecimal reducingAgent;

    @ExcelColumn(header = {"中水药剂", "EDTA-四钠"}, order = 40)
    @ColumnWidth(12)
    private BigDecimal edtaTetrasodium;

    @ExcelColumn(header = {"中水药剂", "盐酸"}, order = 41)
    @ColumnWidth(12)
    private BigDecimal hydrochloricAcid;


    private BigDecimal parseBigDecimal(String value) {
        if (value == null || value.trim().isEmpty() || value.equals("-")) {
            return null;
        }
        try {
            return new BigDecimal(value.trim());
        } catch (NumberFormatException e) {
            // 记录日志或抛出异常，根据实际需求处理
            System.err.println("数值格式错误: " + value);
            return null;
        }
    }

}